from flask import Flask
from app.modes.book import db
from flask_login import LoginManager


# 初始化flask

login_manager=LoginManager()
def create_app():
    app = Flask(__name__)
    app.config.from_object('app.secure')  # 设置读取配置文件的名字路径
    app.config.from_object('app.setting')
    register_blueprint(app)
    db.init_app(app)
    db.create_all(app=app)
    login_manager.init_app(app) #初始化flask_login
    login_manager.login_view='web.login'
    login_manager.login_message='请先登录或注册'
    return app


# 把蓝图注册到app视图
def register_blueprint(app):
    from app.web.book import web
    app.register_blueprint(web)
